<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - gil/extension/io/jpeg_io.hpp</title>
  <link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../../index.html">directory</a> - <a href="index.html">gil/extension/io</a> - jpeg_io.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">7</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">100.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">7</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : /*
<span class="lineNum">       2 </span>                :     Copyright 2005-2007 Adobe Systems Incorporated
<span class="lineNum">       3 </span>                :    
<span class="lineNum">       4 </span>                :     Use, modification and distribution are subject to the Boost Software License,
<span class="lineNum">       5 </span>                :     Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       6 </span>                :     http://www.boost.org/LICENSE_1_0.txt).
<span class="lineNum">       7 </span>                : 
<span class="lineNum">       8 </span>                :     See http://opensource.adobe.com/gil for most recent version including documentation.
<span class="lineNum">       9 </span>                : */
<span class="lineNum">      10 </span>                : 
<span class="lineNum">      11 </span>                : /*************************************************************************************************/
<span class="lineNum">      12 </span>                : 
<span class="lineNum">      13 </span>                : #ifndef GIL_JPEG_IO_H
<span class="lineNum">      14 </span>                : #define GIL_JPEG_IO_H
<span class="lineNum">      15 </span>                : 
<span class="lineNum">      16 </span>                : /// \file
<span class="lineNum">      17 </span>                : /// \brief  Support for reading and writing JPEG files
<span class="lineNum">      18 </span>                : ///         Requires libjpeg
<span class="lineNum">      19 </span>                : /// \author Hailin Jin and Lubomir Bourdev \n
<span class="lineNum">      20 </span>                : ///         Adobe Systems Incorporated
<span class="lineNum">      21 </span>                : /// \date   2005-2007 \n Last updated September 24, 2006
<span class="lineNum">      22 </span>                : 
<span class="lineNum">      23 </span>                : #include &lt;cstdio&gt;
<span class="lineNum">      24 </span>                : #include &lt;algorithm&gt;
<span class="lineNum">      25 </span>                : #include &lt;string&gt;
<span class="lineNum">      26 </span>                : #include &lt;boost/static_assert.hpp&gt;
<span class="lineNum">      27 </span>                : #include &lt;boost/shared_ptr.hpp&gt;
<span class="lineNum">      28 </span>                : extern &quot;C&quot; {
<span class="lineNum">      29 </span>                : #include &lt;jpeglib.h&gt;
<span class="lineNum">      30 </span>                : }
<span class="lineNum">      31 </span>                : #include &quot;io_error.hpp&quot;
<span class="lineNum">      32 </span>                : #include &quot;jpeg_io_private.hpp&quot;
<span class="lineNum">      33 </span>                : 
<span class="lineNum">      34 </span>                : namespace boost { namespace gil {
<span class="lineNum">      35 </span>                : 
<span class="lineNum">      36 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">      37 </span>                : /// \brief Determines whether the given view type is supported for reading
<span class="lineNum">      38 </span>                : template &lt;typename View&gt;
<span class="lineNum">      39 </span>                : struct jpeg_read_support {
<span class="lineNum">      40 </span>                :     BOOST_STATIC_CONSTANT(bool,is_supported=
<span class="lineNum">      41 </span>                :                           (detail::jpeg_read_support_private&lt;typename channel_type&lt;View&gt;::type,
<span class="lineNum">      42 </span>                :                                                              typename color_space_type&lt;View&gt;::type&gt;::is_supported));
<span class="lineNum">      43 </span>                :     BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=
<span class="lineNum">      44 </span>                :                           (detail::jpeg_read_support_private&lt;typename channel_type&lt;View&gt;::type,
<span class="lineNum">      45 </span>                :                                                              typename color_space_type&lt;View&gt;::type&gt;::color_type));
<span class="lineNum">      46 </span>                :     BOOST_STATIC_CONSTANT(bool, value=is_supported);
<span class="lineNum">      47 </span>                : };
<span class="lineNum">      48 </span>                : 
<span class="lineNum">      49 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">      50 </span>                : /// \brief Returns the width and height of the JPEG file at the specified location.
<span class="lineNum">      51 </span>                : /// Throws std::ios_base::failure if the location does not correspond to a valid JPEG file
<span class="lineNum">      52 </span>                : inline point2&lt;std::ptrdiff_t&gt; jpeg_read_dimensions(const char* filename) {
<span class="lineNum">      53 </span>                :     detail::jpeg_reader m(filename);
<span class="lineNum">      54 </span>                :     return m.get_dimensions();
<span class="lineNum">      55 </span>                : }
<span class="lineNum">      56 </span>                : 
<span class="lineNum">      57 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">      58 </span>                : /// \brief Returns the width and height of the JPEG file at the specified location.
<span class="lineNum">      59 </span>                : /// Throws std::ios_base::failure if the location does not correspond to a valid JPEG file
<span class="lineNum">      60 </span>                : inline point2&lt;std::ptrdiff_t&gt; jpeg_read_dimensions(const std::string&amp; filename) {
<span class="lineNum">      61 </span>                :     return jpeg_read_dimensions(filename.c_str());
<span class="lineNum">      62 </span>                : }
<span class="lineNum">      63 </span>                : 
<span class="lineNum">      64 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">      65 </span>                : /// \brief Loads the image specified by the given jpeg image file name into the given view.
<span class="lineNum">      66 </span>                : /// Triggers a compile assert if the view color space and channel depth are not supported by the JPEG library or by the I/O extension.
<span class="lineNum">      67 </span>                : /// Throws std::ios_base::failure if the file is not a valid JPEG file, or if its color space or channel depth are not 
<span class="lineNum">      68 </span>                : /// compatible with the ones specified by View, or if its dimensions don't match the ones of the view.
<span class="lineNum">      69 </span>                : template &lt;typename View&gt;
<span class="lineNum">      70 </span>                : inline void jpeg_read_view(const char* filename,const View&amp; view) {
<span class="lineNum">      71 </span>                :     BOOST_STATIC_ASSERT(jpeg_read_support&lt;View&gt;::is_supported);
<span class="lineNum">      72 </span>                : 
<span class="lineNum">      73 </span>                :     detail::jpeg_reader m(filename);
<span class="lineNum">      74 </span>                :     m.apply(view);
<span class="lineNum">      75 </span>                : }
<span class="lineNum">      76 </span>                : 
<span class="lineNum">      77 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">      78 </span>                : /// \brief Loads the image specified by the given jpeg image file name into the given view.
<span class="lineNum">      79 </span>                : template &lt;typename View&gt;
<span class="lineNum">      80 </span>                : inline void jpeg_read_view(const std::string&amp; filename,const View&amp; view) {
<span class="lineNum">      81 </span>                :     jpeg_read_view(filename.c_str(),view);
<span class="lineNum">      82 </span>                : }
<span class="lineNum">      83 </span>                : 
<span class="lineNum">      84 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">      85 </span>                : /// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, and loads the pixels into it.
<span class="lineNum">      86 </span>                : /// Triggers a compile assert if the image color space or channel depth are not supported by the JPEG library or by the I/O extension.
<span class="lineNum">      87 </span>                : /// Throws std::ios_base::failure if the file is not a valid JPEG file, or if its color space or channel depth are not 
<span class="lineNum">      88 </span>                : /// compatible with the ones specified by Image
<span class="lineNum">      89 </span>                : template &lt;typename Image&gt;
<span class="lineNum">      90 </span><span class="lineCov">              6 : inline void jpeg_read_image(const char* filename,Image&amp; im) {</span>
<span class="lineNum">      91 </span>                :     BOOST_STATIC_ASSERT(jpeg_read_support&lt;typename Image::view_t&gt;::is_supported);
<span class="lineNum">      92 </span>                : 
<span class="lineNum">      93 </span><span class="lineCov">              6 :     detail::jpeg_reader m(filename);</span>
<span class="lineNum">      94 </span><span class="lineCov">              6 :     m.read_image(im);</span>
<span class="lineNum">      95 </span><span class="lineCov">              6 : }</span>
<span class="lineNum">      96 </span>                : 
<span class="lineNum">      97 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">      98 </span>                : /// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, and loads the pixels into it.
<span class="lineNum">      99 </span>                : template &lt;typename Image&gt;
<span class="lineNum">     100 </span><span class="lineCov">              6 : inline void jpeg_read_image(const std::string&amp; filename,Image&amp; im) {</span>
<span class="lineNum">     101 </span><span class="lineCov">              6 :     jpeg_read_image(filename.c_str(),im);</span>
<span class="lineNum">     102 </span><span class="lineCov">              6 : }</span>
<span class="lineNum">     103 </span>                : 
<span class="lineNum">     104 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     105 </span>                : /// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
<span class="lineNum">     106 </span>                : /// Throws std::ios_base::failure if the file is not a valid JPEG file, or if its dimensions don't match the ones of the view.
<span class="lineNum">     107 </span>                : template &lt;typename View,typename CC&gt;
<span class="lineNum">     108 </span>                : inline void jpeg_read_and_convert_view(const char* filename,const View&amp; view,CC cc) {
<span class="lineNum">     109 </span>                :     detail::jpeg_reader_color_convert&lt;CC&gt; m(filename,cc);
<span class="lineNum">     110 </span>                :     m.apply(view);
<span class="lineNum">     111 </span>                : }
<span class="lineNum">     112 </span>                : 
<span class="lineNum">     113 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     114 </span>                : /// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
<span class="lineNum">     115 </span>                : /// Throws std::ios_base::failure if the file is not a valid JPEG file, or if its dimensions don't match the ones of the view.
<span class="lineNum">     116 </span>                : template &lt;typename View&gt;
<span class="lineNum">     117 </span>                : inline void jpeg_read_and_convert_view(const char* filename,const View&amp; view) {
<span class="lineNum">     118 </span>                :     detail::jpeg_reader_color_convert&lt;default_color_converter&gt; m(filename,default_color_converter());
<span class="lineNum">     119 </span>                :     m.apply(view);
<span class="lineNum">     120 </span>                : }
<span class="lineNum">     121 </span>                : 
<span class="lineNum">     122 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     123 </span>                : /// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
<span class="lineNum">     124 </span>                : template &lt;typename View,typename CC&gt;
<span class="lineNum">     125 </span>                : inline void jpeg_read_and_convert_view(const std::string&amp; filename,const View&amp; view,CC cc) {
<span class="lineNum">     126 </span>                :     jpeg_read_and_convert_view(filename.c_str(),view);
<span class="lineNum">     127 </span>                : }
<span class="lineNum">     128 </span>                : 
<span class="lineNum">     129 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     130 </span>                : /// \brief Loads and color-converts the image specified by the given jpeg image file name into the given view.
<span class="lineNum">     131 </span>                : template &lt;typename View&gt;
<span class="lineNum">     132 </span>                : inline void jpeg_read_and_convert_view(const std::string&amp; filename,const View&amp; view) {
<span class="lineNum">     133 </span>                :     jpeg_read_and_convert_view(filename.c_str(),view);
<span class="lineNum">     134 </span>                : }
<span class="lineNum">     135 </span>                : 
<span class="lineNum">     136 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     137 </span>                : /// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
<span class="lineNum">     138 </span>                : /// Throws std::ios_base::failure if the file is not a valid JPEG file
<span class="lineNum">     139 </span>                : template &lt;typename Image,typename CC&gt;
<span class="lineNum">     140 </span>                : inline void jpeg_read_and_convert_image(const char* filename,Image&amp; im,CC cc) {
<span class="lineNum">     141 </span>                :     detail::jpeg_reader_color_convert&lt;CC&gt; m(filename,cc);
<span class="lineNum">     142 </span>                :     m.read_image(im);
<span class="lineNum">     143 </span>                : }
<span class="lineNum">     144 </span>                : 
<span class="lineNum">     145 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     146 </span>                : /// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
<span class="lineNum">     147 </span>                : /// Throws std::ios_base::failure if the file is not a valid JPEG file
<span class="lineNum">     148 </span>                : template &lt;typename Image&gt;
<span class="lineNum">     149 </span>                : inline void jpeg_read_and_convert_image(const char* filename,Image&amp; im) {
<span class="lineNum">     150 </span>                :     detail::jpeg_reader_color_convert&lt;default_color_converter&gt; m(filename,default_color_converter());
<span class="lineNum">     151 </span>                :     m.read_image(im);
<span class="lineNum">     152 </span>                : }
<span class="lineNum">     153 </span>                : 
<span class="lineNum">     154 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     155 </span>                : /// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
<span class="lineNum">     156 </span>                : template &lt;typename Image,typename CC&gt;
<span class="lineNum">     157 </span>                : inline void jpeg_read_and_convert_image(const std::string&amp; filename,Image&amp; im,CC cc) {
<span class="lineNum">     158 </span>                :     jpeg_read_and_convert_image(filename.c_str(),im);
<span class="lineNum">     159 </span>                : }
<span class="lineNum">     160 </span>                : 
<span class="lineNum">     161 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     162 </span>                : /// \brief Allocates a new image whose dimensions are determined by the given jpeg image file, loads and color-converts the pixels into it.
<span class="lineNum">     163 </span>                : template &lt;typename Image&gt;
<span class="lineNum">     164 </span>                : inline void jpeg_read_and_convert_image(const std::string&amp; filename,Image&amp; im) {
<span class="lineNum">     165 </span>                :     jpeg_read_and_convert_image(filename.c_str(),im);
<span class="lineNum">     166 </span>                : }
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     169 </span>                : /// \brief Determines whether the given view type is supported for writing
<span class="lineNum">     170 </span>                : template &lt;typename View&gt;
<span class="lineNum">     171 </span>                : struct jpeg_write_support {
<span class="lineNum">     172 </span>                :     BOOST_STATIC_CONSTANT(bool,is_supported=
<span class="lineNum">     173 </span>                :                           (detail::jpeg_write_support_private&lt;typename channel_type&lt;View&gt;::type,
<span class="lineNum">     174 </span>                :                                                               typename color_space_type&lt;View&gt;::type&gt;::is_supported));
<span class="lineNum">     175 </span>                :     BOOST_STATIC_CONSTANT(J_COLOR_SPACE,color_type=
<span class="lineNum">     176 </span>                :                           (detail::jpeg_write_support_private&lt;typename channel_type&lt;View&gt;::type,
<span class="lineNum">     177 </span>                :                                                              typename color_space_type&lt;View&gt;::type&gt;::color_type));
<span class="lineNum">     178 </span>                :     BOOST_STATIC_CONSTANT(bool, value=is_supported);
<span class="lineNum">     179 </span>                : };
<span class="lineNum">     180 </span>                : 
<span class="lineNum">     181 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     182 </span>                : /// \brief Saves the view to a jpeg file specified by the given jpeg image file name.
<span class="lineNum">     183 </span>                : /// Triggers a compile assert if the view color space and channel depth are not supported by the JPEG library or by the I/O extension.
<span class="lineNum">     184 </span>                : /// Throws std::ios_base::failure if it fails to create the file.
<span class="lineNum">     185 </span>                : template &lt;typename View&gt;
<span class="lineNum">     186 </span>                : inline void jpeg_write_view(const char* filename,const View&amp; view,int quality=100) {
<span class="lineNum">     187 </span>                :     BOOST_STATIC_ASSERT(jpeg_write_support&lt;View&gt;::is_supported);
<span class="lineNum">     188 </span>                : 
<span class="lineNum">     189 </span>                :     detail::jpeg_writer m(filename);
<span class="lineNum">     190 </span>                :     m.apply(view,quality);
<span class="lineNum">     191 </span>                : }
<span class="lineNum">     192 </span>                : 
<span class="lineNum">     193 </span>                : /// \ingroup JPEG_IO
<span class="lineNum">     194 </span>                : /// \brief Saves the view to a jpeg file specified by the given jpeg image file name.
<span class="lineNum">     195 </span>                : template &lt;typename View&gt;
<span class="lineNum">     196 </span>                : inline void jpeg_write_view(const std::string&amp; filename,const View&amp; view,int quality=100) {
<span class="lineNum">     197 </span>                :     jpeg_write_view(filename.c_str(),view,quality);
<span class="lineNum">     198 </span>                : }
<span class="lineNum">     199 </span>                : 
<span class="lineNum">     200 </span>                : } }  // namespace boost::gil
<span class="lineNum">     201 </span>                : 
<span class="lineNum">     202 </span>                : #endif
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
